# makefile
# $@---the first item
# $<---the second item
# $^---all items except the first
# gcc: -c means no linker, -o appoints the output name

# use -pthread when taking multip-threads 

CC	= gcc
MATH	= -m	# complie with math lib: libmath.a
OBJ	= -o
CFLAGS	= -c -o
MT	= -pthread
INCLUDE	= err.o pr_exit.o pr_mask.o fl.o lock_reg.o rwn.o

#cleanup: cleanup.o $(INCLUDE)
#	$(CC) $(OBJ) $@ $^ $(MT)
unblock_write: unblock_write.o $(INCLUDE)
	$(CC) $(OBJ) $@ $^

unblock_write.o: unblock_write.c
	$(CC) $(CFLAGS) $@ $<

err.o: err.c
	$(CC) $(CFLAGS) $@ $<

pr_exit.o: pr_exit.c
	$(CC) $(CFLAGS) $@ $<

pr_mask.o: pr_mask.c
	$(CC) $(CFLAGS) $@ $<

fl.o: fl.c
	$(CC) $(CFLAGS) $@ $<

lock_reg.o: lock_reg.c
	$(CC) $(CFLAGS) $@ $<

rwn.o: rwn.c
	$(CC) $(CFLAGS) $@ $<

clean:
	rm -f unblock_write.o unblock_write $(INCLUDE)
